Repository navigation
Conversation
…t rate series in pp
calculateTrend() filtered observations to those on/after (today - N years) and
took the first survivor as the window start. Monthly and quarterly FRED series
lag the calendar by 1-3 months, so the "1Y" column silently covered 9 months
for CPI and 6 months for real GDP (CPI +2.8% vs the true +3.4% YoY; GDPC1
+0.9% vs +2.1%). Missing observations ("." in FRED) pushed the start further
forward.
- Anchor every window to the latest observation and pick the start as the
observation nearest to (latest - N years); return null when nothing is
within 183 days of the target (sparse annual series).
- Sort observations by date before windowing.
- Series that are already percentages (UNRATE, FEDFUNDS, DGS10, ...) now
report changes in percentage points instead of percent-of-percent
("Fed Funds +807% over 10 years", "GDP Growth Rate +200%"); direction uses a
0.10pp dead band. Extremes and momentum sections use the same units.
- Export the pure functions and guard main() with import.meta.main so the
module is testable; add GenerateAnalysis.test.ts with fixed-date fixtures.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Owner
|
Thanks @davdunc. Confirmed: the trend windows were anchored to today, so lagging monthly and quarterly series reported 9-month and 2-quarter spans as "1Y". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
calculateTrend()inLifeOS/install/skills/USMetrics/Tools/GenerateAnalysis.tsanchored every trend window to today and took the first observation after the cutoff as the start. Monthly and quarterly FRED series lag the calendar by 1–3 months, so the "1Y" column silently covered a shorter span, and FRED's missing-value observations (.) pushed the start further forward.Reproduced on 2026-09-27 against live FRED data (before this change):
A second defect in the same column: percent change applied to series that are already percentages produced lines such as
GDP Growth Rate: +200.0%andFed Funds Rate: +807% over 10 years.Fix
latest − N years.null(rendered—) when no observation lies within tolerance of the target, instead of a mislabelled window. Tolerance is half the series' median observation spacing, floored at 3 days (covers weekends/holidays in daily series).years + 1of history so the 10Y window has a real start candidate for lagged series.RATE_SERIES(UNRATE, FEDFUNDS, DGS10, …) report changes in percentage points;formatValuenow reuses the same set (GDP Growth Rate previously printed as a bare number). OneSCALEtable holds the dead band / "significant move" / momentum thresholds per unit, used by the snapshot, detail tables, extremes and momentum sections.main()withimport.meta.mainso the module is testable; addGenerateAnalysis.test.ts(fixed-date fixtures, no wall-clock dependence).Verification
bun test LifeOS/install/skills/USMetrics/Tools/GenerateAnalysis.test.ts: 14 pass, 0 fail.—cells appear in the live detail tables (every priority series has a start within tolerance for all four horizons).Not in this PR (follow-ups)
Tools/FetchFredSeries.tshas its owncalculateTrendStatswith the same anchored-to-today logic; a shared trend module would let both tools use one implementation.RATE_SERIES,SERIES_NAMESandFetchFredSeries.ts'sCORE_SERIESare three hand-maintained series tables; consolidating them is a larger change.🤖 Generated with Claude Code